Reservoirs Module

History

current version 2.0 - 4th March 2025

version date comment
1.0 05/Oct/2016 Original code
1.1 08/Feb/2023 OutReservoirsInit and OutReservoirs added
1.2 17/Mar/2023 bypass channel simulation included
1.3 28/Nov/2023 manage reservoir when level is high
1.4 12/Dec/2023 eflow is a vector of 365 daily value
1.5 26/Mar/2024 reservoir volume written to output
1.6 10/Apr/2024 observed reservoir downstream discharge read from file
1.7 11/Apr/2024 observed reservoir diverted discharge read from file
1.8 05/May/2024 Qin and Qout channel written even in reservoir without diversion
1.9 04/Sep/2024 modified code to save and read reservoir state variables
2.0 04/Mar/2025 one outlet discharge rule can be assigned for every day of the year

License

license: GNU GPL http://www.gnu.org/licenses/

Module Description

This module includes data and routines to manage reservoirs within the distributed hydrological model Two types of reservoirs are available, on-stream and off-stream reservoirs. On-stream reservoirs are the ones that are located across a river. An off-stream reservoir is a reservoir that is not located on a streambed, and is supplied by an artificial canal or pipeline. In case of off-stream reservoir, the water stored can be released in a downstream section of the same river from which water was withdrawn, or in a different water course. A diversion channel can be associated to a given reservoir. In this case, the diversion channel
diverts water from the reservoir and conveys it to a downstream section of the same river (bypass) or to a different river. The diversion channel is an hydraulic structure typically used to diverts flow to hydroelectric power plant.



Variables

Type Visibility Attributes Name Initial
integer(kind=short), public :: dtReservoir
type(Reservoir), public, POINTER :: pools
integer, private, parameter :: QIN = 1
integer(kind=short), private :: nReservoirs
integer(kind=short), private :: nReservoirsWithDiversion

Derived Types

type, public ::  Reservoir

Components

Type Visibility Attributes Name Initial
real(kind=float), public :: Pout_off
real(kind=float), public :: Qout
real(kind=float), public :: Qout_off
type(Diversion), public :: bypass

diversion channel

logical, public :: bypassIsPresent
integer(kind=short), public :: c

cell column j

integer(kind=short), public :: cout

cell column where off-stream pool outflow is discharged

logical, public :: dischargeDiverted

read observed diverted discharge when true

logical, public :: dischargeDownstream

read observed downstream discharge when true

real(kind=float), public :: eFlow(365)
integer(kind=short), public :: fileunit_out

file unit for writing results

real(kind=float), public :: freeFlow
real(kind=float), public :: freeFlowElevation
real(kind=float), public :: fullReservoirLevel

full reservoir level (m)

type(Table), public :: geometry
integer(kind=short), public :: geometryDOY(365)
logical, public :: highLevel

true when reservoir is managed for high level

integer(kind=short), public :: id
character(len=100), public :: name
type(ObservationalNetwork), public :: network
type(ObservationalNetwork), public :: networkDischargeDiverted
type(ObservationalNetwork), public :: networkDischargeDownstream
type(Reservoir), public, POINTER :: next
integer, public :: qoutRule

determines how to compute Qout

integer(kind=short), public :: r

cell row i

logical, public :: rising

override Qout calculation only when Qin discharge is rising

integer(kind=short), public :: rk

runge-kutta order

integer(kind=short), public :: rout

cell row where off-stream pool outflow is discharged

real(kind=float), public :: stage

current stage [m]

real(kind=float), public :: stageMax

maximum stage [m]

real(kind=float), public :: stageTarget

follow a target (observed) stage [m]

type(DateTime), public :: tReadNewDischargeDiverted
type(DateTime), public :: tReadNewDischargeDownstream
type(DateTime), public :: tReadNewStage
character(len=10), public :: typ

on-stream off-stream by-pass

integer(kind=short), public :: typOut

type ofoutflow: 1=free flow 2=target level

integer(kind=short), public :: unit

file unit target stage

integer(kind=short), public :: unitDischargeDiverted

file unit of observed diverted discharge

integer(kind=short), public :: unitDischargeDownstream

file unit of observed downstream discharge

type(Table), public :: weir
integer(kind=short), public :: weirDOY(365)
real(kind=float), public :: xout

x coordinate where outflow from reservoir is discharged

type(Coordinate), public :: xyz

easting, northing and elevation in real world

real(kind=float), public :: yout

y coordinate where outflow from reservoir is discharged


Functions

public function CountReservoirs(list) result(c)

count number of reservoirs in a list

Arguments

Type IntentOptional Attributes Name
type(Reservoir), intent(in), POINTER :: list

Return Value integer(kind=short)

public function GetReservoirById(list, id) result(p)

given a list of reservoirs, returns a pointer to one reservoir by id

Arguments

Type IntentOptional Attributes Name
type(Reservoir), intent(in), POINTER :: list
integer(kind=short), intent(in) :: id

Return Value type(Reservoir), POINTER

private function SetDailyArray(value) result(array)

populate array of daily values

Arguments

Type IntentOptional Attributes Name
character(len=*) :: value

Return Value real(kind=float), (365)


Subroutines

public subroutine InitReservoirs(filename_ini, tbegin, mask, list)

Initialize reservoirs

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: filename_ini
type(DateTime), intent(in) :: tbegin
type(grid_integer), intent(in) :: mask
type(Reservoir), intent(out), POINTER :: list

public subroutine OutReservoirs(list, time, Qin, Qout)

write results on files

Arguments

Type IntentOptional Attributes Name
type(Reservoir), intent(in), POINTER :: list
type(DateTime), intent(in) :: time
type(grid_real), intent(in) :: Qin
type(grid_real), intent(in) :: Qout

public subroutine OutReservoirsInit(list, path_out)

initialise files for output

Arguments

Type IntentOptional Attributes Name
type(Reservoir), intent(in), POINTER :: list
character(len=*), intent(in) :: path_out

public subroutine ReservoirSaveStatus(pathOut, time)

Save reservoirs status into file

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: pathOut
type(DateTime), intent(in), optional :: time

private subroutine ReadGeometry(iniDB, k, reserv)

read geometry table

Arguments

Type IntentOptional Attributes Name
type(IniList), intent(in) :: iniDB
integer(kind=short), intent(in) :: k
type(Reservoir), intent(inout), POINTER :: reserv

private subroutine ReadWeir(iniDB, k, div)

read weir table

Arguments

Type IntentOptional Attributes Name
type(IniList), intent(in) :: iniDB
integer(kind=short), intent(in) :: k
type(Diversion), intent(inout) :: div

private subroutine ReservoirReadStatus(filename)

Read reservoir stage and diversion discharge from file

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: filename